<?php

namespace app\api\controller;

use app\services\OrderMessageService;
use support\Request;

class OrderMessageController
{
    public function list(Request $request)
    {
        try {
            $page = $request->post('page', 1);
            $length = $request->post('length', 10);

            $data = OrderMessageService::list($page, $length);

            return ok_rsp('成功', $data);
        } catch (\Exception $e) {
            return err_rsp($e->getMessage());
        }
    }

    public function markRead(Request $request)
    {
        try {
            $orderNo = $request->post('order_no');
            OrderMessageService::markRead($orderNo);

            return ok_rsp('成功');
        } catch (\Exception $e) {
            return err_rsp($e->getMessage());
        }
    }
}